<script>

    /*$(function(){
        $.get("/menu/getmenu",function (reulst) {
            var data = reulst.data();
            if (data.code==200){
                $("#sidebar_nav").html("");
                var val = "";
                data.forEach(function(value,index){

                    val = val+ "<li>"+
                        "<a role=\"button\" href=\"/admin/article\">"+
                        "<span class=\"glyphicon glyphicon-file\"></span>"+value.value+"</a>"+
                        "</li>";
                });
                $("#sidebar_nav").append(val)
                alert("菜单加载完成")
            } else {
                layer.msg(data.message,{icon: 5});
            }
        })
//        alert("加载目录")
    });*/


    $(document).ready(function () {
        loadUserInfo()
    })

    function loadUserInfo() {
        //判断是否登录
        $.get("/is/login",function (reulst) {
            if (reulst.length!=0){
                $(".menu_top_img").html('<img src="'+reulst.data.icon+'" >')
            } else {
                $(".menu_top_img").html("")
            }
        });

        $.ajax({
            type: 'get',
            url: '/menu/getmenu',
            dataType:"json",
            data:{
            },
            success: function (result) {
                var data = result.data;
                $("#menu_list").html("")
                var val = "";
                data.forEach(function(value,index){

                    val = val+ "<li>"+
                    "<a role=\"button\" href=\""+value.url+"\">"+
                    "<span class=\"glyphicon glyphicon-file\"></span>"+value.name+"</a></li>";

                });
                $("#menu_list").html(val)
            },
            error:function () {
                layer.msg("系统错误！",{icon: 5});
            }
        });



    }
    function logout() {
        $.get("/logout",function (result) {window.location.reload()})
    }

</script>
<header class="nav">
    <div class="nav_logo">
        <a href="index.html">LOGO</a>
    </div>
    <div class="nav_menu">
        <ul class="nav_menu_ul clear">
            <li>
                <a role="button" href="/admin/user">
                    <span class="glyphicon glyphicon-user"></span>
                    用户管理
                </a>
            </li>
            <li>
                <a role="button" role="button" class="refresh">
                    <span class="glyphicon glyphicon-refresh"></span>
                    刷新
                </a>
            </li>
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                   aria-expanded="false">
                    <span class="glyphicon glyphicon-cog"></span>
                    设置 <span class="caret"></span>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="#">主题切换</a></li>
                    <li><a href="/admin/security">修改密码</a></li>
                    <li><a href="/admin/about">关于</a></li>
                </ul>
            </li>
            <li>
                <a role="button" onclick="logout()">
                    <span class="glyphicon glyphicon-off"></span>
                    退出
                </a>
            </li>
        </ul>
    </div>
</header>
<div class="menu">
    <div class="menu_top">
        <div class="menu_top_img">

        </div>
        <label class="menu_top_name">
            <label for=""><span id="username"></span></label>
        </label>
    </div>
    <ul class="sidebar_nav" id="menu_list">
        <!--<li>
            <a role="button" href="/admin/index">
                <span class="glyphicon glyphicon-home"></span>
                首&nbsp;&nbsp;&nbsp;&nbsp;页
            </a>
        </li>
        <li>
            <a role="button" href="/admin/article">
                <span class="glyphicon glyphicon-file"></span>
                日记本
            </a>
        </li>
        <li>
            <a role="button" href="/admin/message">
                <span class="glyphicon glyphicon-edit"></span>
                留言板
            </a>
        </li>
        <li>
            <a role="button" href="/admin/link">
                <span class="glyphicon glyphicon-magnet"></span>
                友人帐
            </a>
        </li>
        <li>
            <a role="button" href="/admin/music">
                <span class="glyphicon glyphicon-music"></span>
                音乐盒
            </a>
        </li>
        <li>
            <a role="button" href="/admin/about">
                <span class="glyphicon glyphicon-music"></span>
                关&nbsp;&nbsp;&nbsp;&nbsp;于
            </a>
        </li>
        <li>
            <a role="button" href="/admin/function">
                <span class="glyphicon glyphicon-music"></span>
                权&nbsp;&nbsp;&nbsp;&nbsp;限
            </a>
        </li>
        <li>
            <a role="button" href="/admin/role">
                <span class="glyphicon glyphicon-music"></span>
                角&nbsp;&nbsp;&nbsp;&nbsp;色
            </a>
        </li>
        <li>
            <a role="button" href="/admin/user">
                <span class="glyphicon glyphicon-user"></span>
                用&nbsp;&nbsp;&nbsp;&nbsp;户
            </a>
        </li>-->

    </ul>
</div>